import CopyOutlined from '@ant-design/icons/CopyOutlined';
import EyeInvisibleOutlined from '@ant-design/icons/EyeInvisibleOutlined';
import EyeOutlined from '@ant-design/icons/EyeOutlined';
import 'antd/es/message/style/index.js';
import React, { Fragment } from 'react';
import { copy } from '../_utils/dom';
import './index.less';
import useMask from './useMask';
function EnhancedText(_ref) {
  var copyable = _ref.copyable,
    maskable = _ref.maskable,
    maskType = _ref.maskType,
    maskOptions = _ref.maskOptions,
    children = _ref.children;
  var _useMask = useMask({
      data: children,
      maskType: maskType,
      maskOptions: maskOptions,
    }),
    result = _useMask.result,
    masked = _useMask.masked,
    toggle = _useMask.toggle;
  var MaskIcon = masked ? EyeOutlined : EyeInvisibleOutlined;
  return /*#__PURE__*/ React.createElement(
    Fragment,
    null,
    maskable && masked ? result : children,
    maskable &&
      children &&
      /*#__PURE__*/ React.createElement(MaskIcon, {
        className: 'szzj-enhanced-text-mask-icon',
        onClick: toggle,
      }),
    copyable &&
      children &&
      /*#__PURE__*/ React.createElement(CopyOutlined, {
        className: 'szzj-enhanced-text-copy-icon',
        onClick: function onClick() {
          return copy(children);
        },
      }),
  );
}
export default EnhancedText;
